package com.it.data_recursion;

import com.it.data_tree.util.ColorPrintln;

/**
 * @Author: Coke
 * @DateTime: 2023/05/18/22:08
 * @注释: 逆向打印字符串
 **/
public class PrintStr {
    private static StringBuilder builder = new StringBuilder();
    
    private static void reversePrintStr (int index, String str) {
        if (index == str.length()) {
            return;
        }
        reversePrintStr(index + 1, str);
        builder.append(str.charAt(index));
    }
    
    public static void reversePrintStr (String str) {
        reversePrintStr(0, str);
        ColorPrintln.greenPrintln(builder);
    }
}
